<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
	$(document).ready(function(){
		$("#deleteConsumers").click(function(){
			if($("#selectConsumer:checked").size()==0){
				alert("삭제할 회원을 선택 하세요!");
				return;
			}else{
				if(confirm("삭제 하시겠습니까?")){ 	
					$.ajax({
						type:"post",
						url:"deleteConsumers.do",
						data:$("#delForm").serialize(),
						dataType:"json",
						success:function(jsonData){
							$("#consumerView").html("");
							var tbody="<table border='1' cellpadding='5' width='700' id='consumerView'><thead align='center'><tr><th>회원 ID</th><th>회원 이름</th><th>회원 주소</th><th>선택</th></tr></thead><tbody align='center'>";
							$.each(jsonData,function(index,consumerList){
								tbody+="<tr><td><a href='consumerContentView.do?id="+consumerList.id+"'>"+consumerList.id+"</td>";
								tbody+="<td>"+consumerList.name+"</td>";
								tbody+="<td>"+consumerList.address+"</td>";
								tbody+="<td><input type='checkbox' id='selectConsumer' name='selectConsumer' value='"+consumerList.id+"'></td></tr>";
							});
							tbody+="</tbody></table>";
							$("#consumerView").html(tbody);
						}
					});
				}
			}
		});
	});
</script>

<h3>회원 관리</h3>
	<form id="delForm">
	<table border="1" cellpadding="5" width="700" id="consumerView">
		<thead align="center">
			<tr>
				<th>회원 ID</th>
				<th>회원 이름</th>
				<th>회원 주소</th>
				<th>선택</th>
			</tr>
		</thead>
		<tbody align="center">
			<c:forEach var="list" items="${requestScope.consumerList}">		
				<tr>
			    	<td><a href="consumerContentView.do?id=${list.id }">${list.id }</a></td>										
					<td>${list.name }</td>
					<td>${list.address }</td>
					<td><input type="checkbox" id="selectConsumer" name="selectConsumer" value="${list.id }"></td>
				</tr>		
			</c:forEach>
		</tbody>
	</table>
	</form>
	<br>
	<input type="button" id="deleteConsumers" value="삭제하기">